package com.jjz.id.config;

import com.jjz.id.common.filter.CorpFilter;
import com.jjz.id.common.utils.SpringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

/**
 * @author ZJL
 * @create 2025-05-27-16:33
 * 手动注册
 */

public class BeanConfiguration {
    private static final Logger log = LoggerFactory.getLogger(BeanConfiguration.class);


/*    @Bean
    CaptchaCacheService redisCaptchaCacheService() {
        return CaptchaServiceFactory.getCache("redis");
    }*/

    @Bean
    CorpFilter jjzCorpFilter() {
        return new CorpFilter();
    }

    @Bean
    public FilterRegistrationBean CorpFilterRegistrationBean(CorpFilter filter) {
        log.info("init registry jjzCorpFilter!");
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(filter);
        registration.addUrlPatterns(new String[]{"/api/*"});
        registration.setName("jjzCorpFilter");
        registration.setOrder(Integer.MIN_VALUE);
        return registration;
    }
//实现动态获取 Bean 的能力（常用于非 Spring 管理类）
    @Bean
    SpringUtils springUtils() {
        return new SpringUtils();
    }
}
